package org.jcb;

import java.util.List;

import org.jcb.model.ButtonQuizz;

import android.content.Context;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.Button;

public class ChoixArrayAdapter extends ArrayAdapter<ButtonQuizz>   {
	 //private  String[][] numbers ;
	 private ButtonQuizz[] choix ;
	 private int layoutResourceId ;
	 Context context ;
	 OnClickListener onClickListener ;
	
	 public ChoixArrayAdapter(Context context, int layoutResourceId,ButtonQuizz[] choix, OnClickListener onClickListener) {
		super(context, layoutResourceId,choix);
		this.choix = choix ;
		this.context = context;
		this.onClickListener = onClickListener ;
		this.layoutResourceId = layoutResourceId;
	}
	 
	@Override
	    public View getView(int position, View convertView, ViewGroup parent) {
		//Log.i("getView", "depart"  );
		if(convertView == null) {
            convertView = LayoutInflater.from(context).inflate(R.layout.cellmenu,null);
        }
        Button b = (Button) convertView.findViewById(R.id.buttonChoiceQuizz);
        ButtonQuizz c = choix[position] ;
        b.setText(choix[position].getLibelle() + "\n" + choix[position].getStringRepOfStars());
        b.setEnabled(c.isActif() || (position == 0) );
        //b.setId(c.getId());
        b.setOnClickListener(onClickListener);
        return convertView;
	    }	
	
}
